package com.cg.asm.core.util;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cg.asm.core.domain.vo.user.UserLoginVO;
import com.cg.asm.client.CommonUtil;
import com.cg.asm.client.domain.user.UserInfo;

public class AsmCommonUtil {

    // 总控登录信息
    public static String ASMCONTEXELOGINKEY = "ASM-CONTEXE-LOGIN";
    /**
     * 将UserLoginVO转换为UserInfo
     *
     * @param userLoginVO
     * @return
     */
    public static UserInfo UserLoginVOToUserInfo(UserLoginVO userLoginVO) {
        if (null != userLoginVO) {
            UserInfo userInfo = JSON.parseObject(JSON.toJSONString(userLoginVO), UserInfo.class);
            return userInfo;
        } else {
            return null;
        }
    }

    /**
     * 将UserLoginVO转换为UserInfo
     *
     * @param userLoginVO
     * @returnu
     */
    public static JSONObject successUserInfo(UserLoginVO userLoginVO) {
        if (null != userLoginVO) {
            return CommonUtil.successJson(AsmCommonUtil.UserLoginVOToUserInfo(userLoginVO));
        } else {
            return CommonUtil.successJson(null);
        }
    }
}
